<?php

namespace app\admin\controller;

use app\common\controller\Backend;
/**
 *
 *
 * @icon fa fa-circle-o
 */
class Conference1 extends Backend
{
    /**
     * Conference模型对
     * @var \app\admin\model\Conference
     */
    protected $model = null;
    protected $noNeedLogin = ['config', 'verify', 'joinmeeting'];
    protected $noNeedRight = ["*"];
    protected $searchFields = ["conf.serial"];

    public function _initialize()
    {

        parent::_initialize();

    }

    /**
     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
     */




    /***
     * 加入会议
     */
    public function joinmeeting(){



//        if ($this->request->isPost()){
//            $meeting_id = $this->request->request('meeting_id');
//            $type = $this->request->request('type');
//            $client = $this->request->request('client');
//
//            // 验证
//            if (!$meeting_id) {
//                $this->error(__('Please enter a valid meeting ID'));
//            }
//            $mtinfo = Db::name('conference')->where(['serial'=>$meeting_id])->field('id')->find();
//            if (empty($mtinfo)) {
//                $this->error(__('The meeting ID does not exist'));
//            }
//
//            if ($type == 'go') {
//                $nickname = str_replace(' ', '', $this->request->request('nickname'));
//                if (!$nickname) {
//                    $this->error(__('Please enter your nickname'));
//                }
//                if (strlen($nickname) > 20) {
//                    $this->error(__('Nickname must be within 20 characters'));
//                }
//
//                // 获取服务器加密地址
//                $host = $this->request->host();
//                $scheme =  Api::get_scheme();
//                $encrypted_extranet = $this->model->getEncryptedExtranet($meeting_id, $host, $scheme);
//
//                $this->success('Success', $encrypted_extranet.$meeting_id.'?displayName='.$nickname.'&weburl='.$domain);
//            }
//
//            if ($client == 'jw') {
//                $this->success('Success', 'admin/conference/joinmeeting?m='.$meeting_id.'&t=go');
//            }else{
//                $this->success('Success', 'admin/conference/joinmeeting?m='.$meeting_id);
//            }
//        }

//        $meeting_id = $cid = str_replace(' ', '', $this->request->request('m'));
//        $type = $this->request->request('t');
//        $client = $this->request->request('c');
//        $meeting_cid = $this->request->request('cid');
//
//        // 接收已登录后的加入会议的参数
//        $peerName = $this->request->request('peerName');
//        $displayName = $this->request->request('displayName');
//        $PHPSESSID = $this->request->request('PHPSESSID');
//        $token = $this->request->request('token');
//
//        if ($peerName && $displayName && $PHPSESSID && $token && !$meeting_id) {
//            $this->error(__('The meeting ID does not exist'), 'admin/conference/joinmeeting');
//        }
//        if ($meeting_id) {
//            $mtinfo = Db::name('conference')->where(['serial'=>$meeting_id])->field('id')->find();
//            if (empty($mtinfo)) {
//                $this->error(__('The meeting ID does not exist'), 'admin/conference/joinmeeting');
//            }
//        }

        // 获取服务器加密地址
        $host = $this->request->host();
        $scheme = $this->request->scheme();
//        $this->view->assign('encrypted_extranet', $this->model->getEncryptedExtranet($cid, $host, $scheme));
//
//        $this->view->assign('meeting_id', $meeting_id);
//        $this->view->assign('peerName', $peerName);
//        if ($this->auth->isLogin() && !$displayName) {
//            $displayName = $this->auth->nickname;
//        }
//        $this->view->assign('displayName', $displayName);
//        $this->view->assign('PHPSESSID', $PHPSESSID);
//        $this->view->assign('token', $token);
//
//        $showMeetingIdForm = ($client == 'jw') ? 1 : 0;
//        $this->view->assign('client', $client);
//        $this->view->assign('showMeetingIdForm', $showMeetingIdForm);
//        $this->view->assign('meeting_cid', $meeting_cid);
//
//        $join = $this->request->request('join');
//        $this->view->assign('join', $join);
//        $this->view->engine->layout(false); // 临时关闭当前模板的布局功能，将无法使用框架的js
//        if ($type == 'go') {
//            if ($this->auth->isLogin()) {
//                $this->view->assign('displayName', $this->auth->nickname);
//            }
//            return $this->view->fetch('join_go');
//        }else{
//            if (config("web_platform") == "umefit"){
//                return $this->view->fetch("joinmeeting_umefit");
//            }
//            return $this->view->fetch();
//        }
//        $this->view->assign('title', __('Join a meeting'));
//        $this->view->engine->layout(false); // 临时关闭当前模板的布局功能，将无法使用框架的js
//        if ($type == 'go') {
//            if ($this->auth->isLogin()) {
//                $this->view->assign('displayName', $this->auth->nickname);
//            }
//            return $this->view->fetch('join_go');
//        }else{
//            if (config("web_platform") == "umefit"){
//                return $this->view->fetch("joinmeeting_umefit");
//            }
//            return $this->view->fetch();
//        }

        return $this->view->fetch();
    }






























}
